﻿using System.Collections;
using System.IO;

namespace QAHelper.Common
{
    public class CSVLogger
    {
        //const string delimeter = "|";

        public void WriteCSV(string filename, ArrayList fileContent)
        {
            //Removes the header text if the file already exists
            if (File.Exists(filename))
                fileContent.RemoveAt(0);

            using (StreamWriter writer = new StreamWriter(filename, true))
            {
                foreach (string temp in fileContent)
                {
                    writer.WriteLine(temp);
                }
            }
        }

        public void UpdateCSV(string filename, ArrayList fileContent)
        {
            //Delete the file if already exists
            //if (File.Exists(filename))
            //    File.Delete(filename);

            using (StreamWriter writer = new StreamWriter(filename))
            {
                foreach (string temp in fileContent)
                {
                    writer.WriteLine(temp);
                }
            }
        }
    }
}
